package com.jishuo.nontax.bean.vo;

import com.jishuo.base.util.StringObject;
import com.jishuo.base.util.StringUtil;
import com.jishuo.nontax.bean.bank.ChargeBill;
import com.jishuo.nontax.bean.bank.ChargeBillDetail;
import com.jishuo.nontax.bean.bank.ChargeBillIsActive;
import com.jishuo.nontax.bean.message.*;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;


/**
 * 缴款书详细信息
 *
 * @author hlp
 * @email 1459875748@qq.com
 * @date 2023-02-02 10:13:13
 */
@Data
public class ChargeBillVO implements Serializable {
    private static final long serialVersionUID = 1L;

    //流水号
    private Long billid;
    //票据种类唯一标识号
    private Integer billtypeid;
    //票据号
    private String billnum;
    //行政区划
    private Long cantonid;
    //执收单位唯一标识号
    private Long unitid;
    //填制日期
    private String filldate;
    //缴款人
    private String payer;
    //缴款人账号
    private String payeraccount;
    //缴款人开户银行
    private String payerbank;
    //收款账户ID
    private Long bankid;
    //收款人
    private String payee;
    //收款人账号
    private String payeeaccount;
    //收款人开户银行
    private String payeebank;
    //备注
    private String memo;
    //校验码
    private String vertifycode;
    //票面总金额
    private BigDecimal originfund;
    //当前金额
    private BigDecimal currentfund;
    //缴款方式
    private Integer payway;
    /** 是否待查确认，对应iswaitaffirm */
    private int incomeway;
    //是否银行确认收款
    private int isbankaffirm;
    //银行交易流水号
    private String bankaffirm;
    //银行收款时间
    private String paybankdt;
    //银行网点
    private String bankstation;
    //单据状态
    private int billstate;
    //是否手工票  0否1是
    private int ishand;
    //经办日期
    private String writedate;
    //大厅
    private Long hallid;
    //字轨
    private Integer keyword;
    //款据过期时间
    private String overduedate;
    //
    private String sn;
    //是否分成缴款书
    private Integer isscale;
    //
    private Integer issend;
    //
    private Long messageid;
    //
    private String writename;
    //
    private String eticketnum;
    //发送时间
    private String sendtime;
    //银行核心交易流水号
    private String hxbankaffirm;

//    private Integer iswaitaffirm;
    private String paywaycode;

    private String cantoncode;
    private String cantonname;
    private String unitcode;
    private String unitname;
    private String billcode;
    private String billname;
    private String keywordcode;
    private String keywordname;
    private String accountcode;
    private String accountname;
    private String bankname;
    private String backout;
    private String remark;
    private String backoutname;
    private String accountcode1;
    private String bankaffirm1;

    private ArrayList<SetChargeBillDetailDTO> chargebilldetail;
    private ArrayList<ChargeBillDetailVO> detailVOS;
    public ChargeBillVO() {};

    public ChargeBillVO(String billnum) {
        this.billnum = billnum;
    }


    public ChargeBillIsActive gainChargeBillIsActive(){
        ChargeBillIsActive bean = new ChargeBillIsActive();

        bean.setBilltype(StringObject.objectString(this.billtypeid));
        bean.setKeyword(StringObject.objectString(this.keyword));
        bean.setBillnum(this.billnum);
        bean.setUnitid(StringObject.objectString(this.unitid));
        bean.setUnitcode(this.unitcode);
        bean.setUnitname(this.unitname);
        bean.setCantonid(StringObject.objectString(this.cantonid));
        bean.setCantoncode(this.cantoncode);
        bean.setCantonname(this.cantonname);
        bean.setBillstate(StringObject.objectString(this.billstate));

        return bean;
    }

    public SetChargeBillIsActive gainSetChargeBillIsActive(){
        SetChargeBillIsActive bean = new SetChargeBillIsActive();

        bean.setBillnum(this.billnum);
        bean.setBilltype(StringObject.objectString(this.billtypeid));
        bean.setCantonid(StringObject.objectString(this.cantonid));
        bean.setKeyword(StringObject.objectString(this.keyword));
        bean.setUnitid(StringObject.objectString(this.unitid));

        return bean;
    }

    public ChargeBillVO(SetCheckDataDTO bean){
        if(bean.getBillid()!=null){
            this.billid =Long.valueOf(bean.getBillid());
        }
        if(bean.getFunds()!=null){
            this.originfund=new BigDecimal(bean.getFunds());
        }
        if(bean.getBankid()!=null){
            this.bankid=Long.valueOf(bean.getBankid());
        }

        this.billnum=bean.getBillnum();
        this.paybankdt=bean.getPaybankdt();
        this.bankaffirm=bean.getBankaffirm();
    }

    public ChargeBillVO(SetChargeBill bean){
        this.billnum = bean.getBillnum();
        this.filldate = bean.getFilldate();
        if(bean.getBankid()!=null){
            this.bankid = Long.valueOf(bean.getBankid());
        }
        if(bean.getOriginfund()!=null){
            this.originfund = new BigDecimal(bean.getOriginfund());
        }
        if(bean.getBillid()!=null){
            this.billid = Long.valueOf(bean.getBillid());
        }
        if(bean.getCantonid()!=null){
            this.cantonid = Long.valueOf(bean.getCantonid());
        }
        if(bean.getUnitid()!=null){
            this.unitid = Long.valueOf(bean.getUnitid());
        }
        if(bean.getHallid()!=null){
            this.hallid = Long.valueOf(bean.getHallid());
        }
        this.payer = bean.getPayer();
        this.payeraccount = bean.getPayeraccount();
        this.payerbank = bean.getPayerbank();
        this.vertifycode = bean.getVertifycode();
        if(bean.getIsscale()!=null){
            this.isscale = Integer.valueOf(bean.getIsscale());
        }
        this.eticketnum = bean.getEticketnum();
        this.chargebilldetail=bean.getChargebilldetail();
    }


    public ChargeBill gainChargeBill(){
        ChargeBill bean = new ChargeBill();

        bean.setBillnum(this.billnum);
        bean.setFilldate(this.filldate);
        bean.setBankid(StringObject.objectString(this.bankid));
        bean.setOriginfund(StringObject.objectString(this.originfund));
        bean.setBillid(StringObject.objectString(this.billid));
        bean.setCantonid(StringObject.objectString(this.cantonid));
        bean.setCantoncode(this.cantoncode);
        bean.setCantonname(this.cantonname);
        bean.setUnitid(StringObject.objectString(this.unitid));
        bean.setUnitcode(this.unitcode);
        bean.setUnitname(this.unitname);
        bean.setHallid(StringObject.objectString(this.hallid));
        bean.setBilltypeid(StringObject.objectString(this.billtypeid));
        bean.setBillcode(this.billcode);
        bean.setBillname(this.billname);
        bean.setKeyword(StringObject.objectString(this.keyword));
        bean.setKeywordcode(this.keywordcode);
        bean.setKeywordname(this.keywordname);
        bean.setPayer(this.payer);
        bean.setPayeraccount(this.payeraccount);
        bean.setPayerbank(this.payerbank);
        bean.setPayeeaccount(this.payeeaccount);
        bean.setPayee(this.payee);
        bean.setPayeebank(this.payeebank);
        bean.setVertifycode(this.vertifycode);
        bean.setIsscale(StringObject.objectString(this.isscale));
        bean.setBillstate(StringObject.objectString(this.billstate));

        ArrayList<ChargeBillDetail> chargeBills = new ArrayList<>();
        if(this.getDetailVOS()!=null){
            for (ChargeBillDetailVO detailVO : this.getDetailVOS()) {
                chargeBills.add(detailVO.getChargeBillDetail());
            }
        }

        bean.setDetail(chargeBills);
        return bean;
    }

    public ChargeBillVO(SetChargeBillManual bean){
        this.billnum=bean.getBillnum();
        if(bean.getCantonid()!=null){
            this.cantonid = Long.valueOf(bean.getCantonid());
        }
        if(bean.getUnitid()!=null){
            this.unitid=Long.valueOf(bean.getUnitid());

        }
        if(bean.getBankid()!=null){
            this.bankid=Long.valueOf(bean.getBankid());
        }
        this.filldate=bean.getFilldate();
        this.payer = bean.getPayer();
        this.payeraccount=bean.getPayeraccount();
        this.payerbank= bean.getPayerbank();
        this.payee=bean.getPayee();
        this.payeeaccount=bean.getPayeeaccount();
        this.payeebank=bean.getPayeebank();
        this.memo=bean.getMemo();
        this.vertifycode=bean.getVertifycode();
        this.originfund=new BigDecimal(bean.getOriginfund());
        this.bankaffirm=bean.getBankaffirm();
        this.paybankdt=bean.getPaybankdt();
        this.bankstation=bean.getBankstation();
        if(bean.getIshand()!=null){
            this.ishand=Integer.parseInt(bean.getIshand());
        }
        if(bean.getHallid()!=null){
            this.hallid=Long.valueOf(bean.getHallid());
        }
        if(bean.getKeyword()!=null){
            this.keyword=Integer.valueOf(bean.getKeyword());
        }
        if(bean.getIsscale()!=null){
            this.isscale=Integer.valueOf(bean.getIsscale());
        }
        this.writedate=bean.getWritedate();
        this.writename=bean.getWritename();
        this.eticketnum=bean.getEticketnum();
        if(bean.getIswaitaffirm()!=null){
            this.incomeway=Integer.valueOf(bean.getIswaitaffirm());
        }
    }

    public SetChargeBillDeposit gainSetChargeBillDeposit(){
        SetChargeBillDeposit bean = new SetChargeBillDeposit();
        bean.setBillnum(this.billnum);
        bean.setEticketnum(this.eticketnum);
        bean.setPayer(this.payer);
        bean.setFilldate(this.filldate);
        bean.setBankid(StringObject.objectString(this.bankid));
        bean.setIswaitaffirm(StringObject.objectString(this.incomeway));
        bean.setOriginfund(this.originfund.toPlainString());
        bean.setPaybankdt(this.paybankdt);
        bean.setBankaffirm(this.bankaffirm);
        bean.setBankstation(this.bankstation);
        bean.setBillid("0");
        bean.setPaywayid(StringUtil.toStr(this.payway));
        return bean;
    }

    public GetChargeBill gainGetChargeBill(){
        GetChargeBill bean = new GetChargeBill();
        bean.setKeyword(StringObject.objectString(this.keyword));
        bean.setBilltype(StringObject.objectString(this.billtypeid));
        bean.setBillnum(this.billnum);

        return bean;
    }


}
